/*
 Copyright (c) 2013 MeherTJ G. All rights reserved.
 License: LGPL for personnal study or free software.
 */

#include "zen_app_mac.h"

#if ZEN_OS_OSX && ZEN_IS_GUI
#include "AppMetalDelegate.h"
#include "zen_log.h"

std::shared_ptr<AppMac> AppMac::_me = std::make_shared<AppMac>();

Zen::App * Zen::App::Instance()
{
    return AppMac::Instance();
}


void AppMac::Update
{
    m_delegate->OnUpdate();
}

void AppMac::draw()
{
    m_delegate->OnDraw();
}

void AppMac::launch(Zen::P2i view_size)
{
    Zen::LogD("---\napp launch ok\nscreen_size:%.2f %.2f\n"
              "rotatable:%d\nfps:%.2f\n---",
              view_size.x, view_size.y,
              (int)IsRotatable(),
              (float)GetFramesPerSecond()
              );
    
    m_delegate->OnLaunch(view_size);
    mSize = view_size;
}

void AppMac::resize(Zen::P2i view_size)
{
	Zen::LogD("---\napp resize\nscreen_size:%.2f %.2f\n"
		   "rotatable:%d\nfps:%.2f\n---",
		   view_size.x, view_size.y,
		   (int)IsRotatable(),
		   (float)GetFramesPerSecond()
		   );
    m_delegate->OnResize(view_size);
    mSize = view_size;
}

void AppMac::exit()
{
    m_delegate->OnExit();
}

void AppMac::pause()
{
    if(m_is_paused) return;
    m_is_paused = true;
    m_delegate->OnPause();
}

void AppMac::resume()
{
    if(!m_is_paused) return;
    m_delegate->OnResume();
    m_is_paused = false;
}

void AppMac::touchDown(Zen::AppTouch touch)
{
    m_delegate->OnTouchDown(touch);
}

void AppMac::touchUp(Zen::AppTouch touch)
{
    m_delegate->OnTouchUp(touch);
}

void AppMac::touchCancel(Zen::AppTouch touch)
{
    m_delegate->OnTouchCancel(touch);
}

void AppMac::touchMove(Zen::AppTouch touch)
{
    m_delegate->OnTouchMove(touch);
}
#endif
